/*******************************************************************************
 * Copyright (c) 2006 CEA List.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     CEA List - initial API and implementation
 *******************************************************************************/
package com.cea.papyrus.diagram.classdiagram.helper;

import com.cea.papyrus.core.IPapyrusUIConstants;
import com.cea.papyrus.core.helper.DefaultModelerHelper;
import com.cea.papyrus.core.helper.EdgeInstanceSpecificationHelper;
import com.cea.papyrus.core.helper.IGraphElementHelper;
import com.cea.papyrus.core.helper.NodeHelper;
import com.cea.papyrus.core.helper.NodeMetaclassHelper;

/**
 * 
 * 
 * @author Patrick Tessier
 * 22 juin 06
 */
public class ClassDiagramModelerHelper extends DefaultModelerHelper {

	/**
	 * 
	 */
	private static ClassDiagramModelerHelper EINSTANCE; 

	// set Uml element that can be created
	/**
	 * 
	 */
	protected final Class elementTypes[] = {
			org.eclipse.uml2.uml.Element.class,
			org.eclipse.uml2.uml.Class.class,
			org.eclipse.uml2.uml.Package.class,
			org.eclipse.uml2.uml.Stereotype.class,
			org.eclipse.uml2.uml.Model.class,
			org.eclipse.uml2.uml.Profile.class,
			org.eclipse.uml2.uml.Property.class,
			org.eclipse.uml2.uml.Operation.class,
			org.eclipse.uml2.uml.Parameter.class,
			org.eclipse.uml2.uml.PrimitiveType.class,
			org.eclipse.uml2.uml.DataType.class,
			org.eclipse.uml2.uml.Enumeration.class,
			org.eclipse.uml2.uml.EnumerationLiteral.class,
			org.eclipse.uml2.uml.Comment.class,
			org.eclipse.uml2.uml.Component.class,
//			org.eclipse.uml2.uml.Node.class,
//			org.eclipse.uml2.uml.Artifact.class,
			org.eclipse.uml2.uml.Constraint.class,
			org.eclipse.uml2.uml.Interface.class,
			org.eclipse.uml2.uml.Signal.class,
			org.eclipse.uml2.uml.Reception.class,
			org.eclipse.uml2.uml.InstanceSpecification.class,
			org.eclipse.uml2.uml.Slot.class,
			com.cea.papyrus.core.pseudoelement.Metaclass.class,
			org.eclipse.uml2.uml.OpaqueExpression.class,
			org.eclipse.uml2.uml.FunctionBehavior.class,
			
			// template
			org.eclipse.uml2.uml.RedefinableTemplateSignature.class,
			org.eclipse.uml2.uml.TemplateSignature.class,
			org.eclipse.uml2.uml.ClassifierTemplateParameter.class,
			org.eclipse.uml2.uml.OperationTemplateParameter.class,
			org.eclipse.uml2.uml.ConnectableElementTemplateParameter.class,
			org.eclipse.uml2.uml.TemplateParameter.class,
			
			// edges
			org.eclipse.uml2.uml.Dependency.class,
			org.eclipse.uml2.uml.Generalization.class,
			org.eclipse.uml2.uml.Association.class,
			org.eclipse.uml2.uml.Extension.class,
			org.eclipse.uml2.uml.ElementImport.class,
			org.eclipse.uml2.uml.PackageImport.class,
			org.eclipse.uml2.uml.InterfaceRealization.class,
			org.eclipse.uml2.uml.Realization.class,
			org.eclipse.uml2.uml.Abstraction.class,
			org.eclipse.uml2.uml.Usage.class,
			com.cea.papyrus.core.pseudoelement.InstanceSpecificationLink.class,
			org.eclipse.uml2.uml.ProfileApplication.class,
			org.eclipse.uml2.uml.TemplateBinding.class,
			com.cea.papyrus.core.pseudoelement.GraphicalLink.class
	};
	
	// set of factory that are in the same order that elment types
	/**
	 * 
	 */
	protected final IGraphElementHelper nodeFactory[] = {
			new NodeHelper(),
			new NodeClassHelper(),
			new NodePackageHelper(),
			new NodeStereotypeHelper(),
			new NodeModelHelper(),
			new NodeProfileHelper(),
			new NodePropertyHelper(),
			new NodeOperationHelper(),
			new NodeParameterHelper(),
			new NodePrimitiveTypeHelper(),
			new NodeDataTypeHelper(),
			new NodeEnumerationHelper(),
			new NodeEnumerationLiteralHelper(),
			new NodeCommentHelper(),
			new NodeComponentHelper(),
//			new NodeDeploymentNodeFactory(),
//			new NodeArtifactHelper(),
			new NodeConstraintHelper(),
			new NodeInterfaceHelper(),
			new NodeSignalHelper(),
			new NodeReceptionHelper(),
			new NodeInstanceSpecificationHelper(),
			new NodeSlotHelper(),
			new NodeMetaclassHelper(),
			new NodeHelper(),
			new NodeFunctionBehaviorHelper(),
			
			// template signature
			new NodeRedefinableTemplateSignatureHelper(),
			new NodeTemplateSignatureHelper(),
			new NodeClassifierTemplateParameterHelper(),
			new NodeOperationTemplateParameterHelper(),
			new NodeConnectableElementTemplateParameterHelper(),
			new NodeTemplateParameterHelper(),
			
			// edges
			new EdgeDependencyHelper(),
			new EdgeGeneralizationHelper(),
			new EdgeAssociationHelper(),
			new EdgeExtensionHelper(),
			new EdgeElementImportHelper(),
			new EdgePackageImportHelper(),
			new EdgeInterfaceRealizationHelper(),
			new EdgeRealizationHelper(),
			new EdgeAbstractionHelper(),
			new EdgeUsageHelper(),
			new EdgeInstanceSpecificationHelper(),
			new EdgeProfileApplicationHelper(),
			new EdgeTemplateBindingHelper(),
			new EdgeGraphLinkHelper()
	};
	
	/**
	 * Create the helpers for model elements.
	 */
	public ClassDiagramModelerHelper() {
		// Create Factories
		for(int i=0; i<this.elementTypes.length; i++){
			this.creationFactoryMap.put( this.elementTypes[i], this.nodeFactory[i]);}	
	}
	
	
	/**
	 * 
	 * 
	 * @return this instance of ModelResourceManager
	 */
	public static ClassDiagramModelerHelper getInstance(){
		if (EINSTANCE==null){
			EINSTANCE=new ClassDiagramModelerHelper();
		}
		return EINSTANCE;
	}

	/* (non-Javadoc)
	 * @see com.cea.papyrus.common.factories.IModelerFactory#getId()
	 */
	/**
	 * 
	 * 
	 * @return 
	 */
	@Override
	public String getId() {
		return IPapyrusUIConstants.CLASS_DIAGRAM;
	}

}
